<template>
	<view class="box">
		<!-- MyTabs 组件，支持同步传值 -->
		<MyTabs :tabs="tabs" :currentTab.sync="currentTab" @update:currentTab="handleTabChange"
			@tab-change="handleTabChange" :tabMessages="tabMessages" :notifications="notifications" />

		<view class="content">
			<!-- 切换内容 -->
			<view v-if="currentTab === 0">
				<uptodate :listData="list" />
			</view>
			<view v-if="currentTab === 1">
				<Unresolved :listData="list1" />
			</view>
			<view v-if="currentTab === 2">
				<resolved :listData="list2" />
			</view>
		</view>

		<!-- 添加任务按钮 -->
		<view class="tianjia" @click="tanchuang">
			<image style="height: 170rpx; width: 170rpx;"
				src="http://openapi.keyboardadmin.com:9001/KingdeeCommunity/add@2x.png" mode="" />
		</view>

		<!-- 选择框 -->
		<!-- <Selectionbox /> -->
	</view>
</template>

<script>
	import {
		defineComponent
	} from 'vue'; // Vue 3 的写法
	import MyTabs from '../../components/Mymaintenance/My_maintenance.vue';
	import resolved from '../../components/Homepagestatus/resolved.vue'; // 已解决
	import Unresolved from '../../components/Homepagestatus/Unresolved.vue'; // 未解决
	import uptodate from '../../components/Homepagestatus/uptodate.vue'; // 最新

	export default defineComponent({
		components: {
			MyTabs,
			uptodate,
			resolved,
			Unresolved,
			// Selectionbox, 选择框组件可以根据需求取消注释
		},
		props: {
			tabMessages: {
				type: [Array, Object], // 根据实际传递的数据类型来确定，这里假设可能是数组或者对象
				default: () => [] // 设置默认值，同样根据实际情况调整，比如如果是对象可以设置为 {}
			},
		},
		data() {
			return {
				currentTab: 0, // 当前选中的标签页
				tabs: [{
						name: '最新'
					},
					{
						name: '未解决'
					},
					{
						name: '解决'
					}
				],
				list: [{
						fid: 0,
						title: "金蝶安装时提示缺少组件，怎么办?",
						answers: "@李小龙",
						date: "2024-05-2012:45",
						message: 4,
						name: "张伟",
						department: "IT支持部",
						corporatename: "杭州晨光科技有限公司"
					},
					{
						fid: 1,
						title: "如何解决金蝶安装中的文件权限问题?",
						answers: "@王菲",
						date: "2024-05-2012:50",
						message: 2,
						name: "刘敏",
						department: "财务部",
						corporatename: "上海鸿运贸易有限公司"
					},
					{
						fid: 2,
						title: "金蝶升级时出现错误提示，怎么处理?",
						answers: "@周杰伦",
						date: "2024-05-2012:55",
						message: 5,
						name: "陈欢",
						department: "系统维护部",
						corporatename: "北京百盛科技有限公司"
					},
					{
						fid: 3,
						title: "安装金蝶后无法正常启动，如何解决?",
						answers: "@范玮琪",
						date: "2024-05-2013:00",
						message: 3,
						name: "王晓",
						department: "技术支持部",
						corporatename: "广州天盈科技有限公司"
					},
					{
						fid: 4,
						title: "金蝶提示网络连接失败，怎么办?",
						answers: "@蔡依林",
						date: "2024-05-2013:10",
						message: 6,
						name: "赵强",
						department: "客服部",
						corporatename: "深圳创新科技有限公司"
					}
				],
				list1: [{
						fid: 5,
						title: "金蝶软件运行缓慢，如何优化？",
						answers: null,
						date: "2024-09-29 10:00",
						message: null,
						name: "李明",
						department: "技术部",
						corporatename: "广州宏图科技有限公司"
					},
					{
						fid: 6,
						title: "金蝶数据备份失败，原因是什么？",
						answers: null,
						date: "2024-09-29 11:30",
						message: null,
						name: "王丽",
						department: "财务部",
						corporatename: "上海瑞丰贸易有限公司"
					},
					{
						fid: 7,
						title: "金蝶报表生成错误，怎么处理？",
						answers: null,
						date: "2024-09-29 14:15",
						message: null,
						name: "张峰",
						department: "运营部",
						corporatename: "北京华宇科技有限公司"
					}
				],
				list2: [{
						fid: 8,
						title: "金蝶登录异常，如何解决？",
						answers: "@专家解答：检查网络连接和账号密码是否正确。",
						date: "2024-09-29 15:00",
						message: null,
						name: "刘强",
						department: "IT 支持部",
						corporatename: "深圳卓越科技有限公司"
					},
					{
						fid: 9,
						title: "金蝶打印设置问题，怎么办？",
						answers: "@专业人士回复：在金蝶软件中调整打印参数，确保打印机连接正常。",
						date: "2024-09-29 16:30",
						message: null,
						name: "陈丽",
						department: "行政部",
						corporatename: "杭州星辰科技有限公司"
					},
					{
						fid: 10,
						title: "金蝶数据导入错误，怎么处理？",
						answers: "@高手支招：检查数据格式是否正确，按照金蝶要求的格式进行导入。",
						date: "2024-09-29 18:00",
						message: null,
						name: "王强",
						department: "销售部",
						corporatename: "南京辉煌科技有限公司"
					}
				]
			};
		},
		methods: {
			// 跳转到任务发布页面
			tanchuang() {
				uni.navigateTo({
					url: '/pages/Postaquestion/Postaquestion'
				});
				console.log("跳转到发布任务页面");
			},
			handleTabChange(newTab) {
				this.currentTab = newTab;
				console.log('当前选中的标签索引:', newTab); // 打印当前选中的标签索引
			},
		}
	});
</script>

<style scoped>
	.box {
		height: 100vh;
		background-color: #F6F6F6;
	}

	.tianjia {
		position: fixed;
		right: 80rpx;
		bottom: 120rpx;
	}

	.content {
		padding: 0 10rpx;
		padding-bottom: 20rpx;
	}
</style>